package com.neusoft.elmboot.controller;

import com.neusoft.elmboot.po.Business;
import com.neusoft.elmboot.po.BusinessGet;
import com.neusoft.elmboot.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Business")
public class BusinessController {
    @Autowired
    private BusinessService businessService;

    @GetMapping("/Login")
    public BusinessGet getBusinessByIdByPass(Business business) throws Exception {
        return businessService.getBusinessByIdByPass(business);
    }
    
    @GetMapping("/OrderTypeId")
    public List<BusinessGet> listBusinessByOrderTypeId(Business business) throws Exception {
        return businessService.listBusinessByOrderTypeId(business.getOrderTypeId());
    }

    @GetMapping("/BusinessId")
    public BusinessGet getBusinessById(Business business) throws Exception {
        return businessService.getBusinessById(business.getBusinessId());
    }
    
    @PostMapping("/BusinessId")
	public int saveBusiness(Business business) throws Exception {
		return businessService.saveBusiness(business);
	}

	@PutMapping("/BusinessId")
	public int updateBusiness(Business business) throws Exception {
		return businessService.updateBusiness(business);
	}

	@DeleteMapping("/BusinessId")
	public int removeBusiness(Business business) throws Exception {
		return businessService.removeBusiness(business.getBusinessId());
	}
	
	@GetMapping("/NewId")
    public int getNewIds() throws Exception {
        return businessService.getNewIds();
    }
	
}
